Serverless Handbook: Dive into modern backend. Understand any backend. by Swizec Teller

Serverless Handbook: Dive into modern backend. Understand any backend. by Swizec Teller

Author:Swizec Teller [Teller, Swizec]
Language: eng
Format: azw3, epub, pdf
Published: 2021-03-27T16:00:00+00:00


deleteItem()

The deleteItem() mutation is simple. GraphQL and the database do the work for us.

// src/mutations.ts export const deleteItem = async (_: any, args: { id: string }) => { // DynamoDB handles deleting already deleted objects, no error :) const item = await db.deleteItem({ TableName: process.env.ITEM_TABLE!, Key: { itemId: args.id, }, ReturnValues: "ALL_OLD", }) return remapProps(item.Attributes) }

We take the id from mutation arguments, ask our database to delete the row, and return the old attributes.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.